package com.wx.stream.rbp.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * @author: 王霄
 * @date: 2022/1/27 16:17
 **/
@Component
@EnableBinding(Source.class)
public class DefaultMessageProvider implements IMessageProvider {

    @Resource
    private MessageChannel output;

    @Override
    public void send() {
        String uuid = UUID.randomUUID().toString();
        Message<String> message = MessageBuilder.withPayload(uuid).build();
        output.send(message);
    }
}
